package com.ywl.designpattern.iterator;

public class IteratorPatternDemo {
    public static void main(String[] args) {
        BookShelf bookShelf = new BookShelf();
        bookShelf.addBook(new Book("Book 1"));
        bookShelf.addBook(new Book("Book 2"));
        bookShelf.addBook(new Book("Book 3"));

        Iterator<Book> iterator = bookShelf.getIterator();
        while (iterator.hasNext()) {
            Book book = iterator.next();
            System.out.println("Book: " + book.getName());
        }
    }
}
